﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;

namespace XnaGameStudio1.Engine
{
    //-----------------------------------------------------------------------------------------------
    class Camera
    {
        public Vector3 AvatarHeadOffset { get; set; }
        public Vector3 TargetOffset { get; set; }
        public Matrix ViewMatrix { get; set; }
        public Matrix ProjectionMatrix { get; set; }

        //-------------------------------------------------------------------------------------------
        public Camera(int width, int height)
        {
            AvatarHeadOffset = new Vector3(0, 7, -15);
            TargetOffset = new Vector3(0, 5, 0);
            ViewMatrix = Matrix.CreateLookAt(
                new Vector3(0.0f, 0.0f, -1.0f), Vector3.Zero, Vector3.Up
                );
            ProjectionMatrix = Matrix.CreateOrthographic(width, height, 0.1f, 10000.0f);
        }

        public void Update(float avatarYaw, Vector3 position, float aspectRatio)
        {
            /*
             * Matrix rotationMatrix = Matrix.CreateRotationY(avatarYaw);

            Vector3 transformedheadOffset =
                Vector3.Transform(AvatarHeadOffset, rotationMatrix);
            Vector3 transformedReference =
                Vector3.Transform(TargetOffset, rotationMatrix);

            Vector3 cameraPosition = position + transformedheadOffset;
            Vector3 cameraTarget = position + transformedReference;

            //Calculate the camera's view and projection 
            //matrices based on current values.
            ViewMatrix =
                Matrix.CreateLookAt(cameraPosition, cameraTarget, Vector3.Up);
            ProjectionMatrix =
                Matrix.CreatePerspectiveFieldOfView(
                    MathHelper.ToRadians(EngineConstants.ViewAngle), aspectRatio,
                    EngineConstants.NearClip, EngineConstants.FarClip);
            */
        }

    }
}
